--DO NOT MODIFY THIS FILE. IT IS ALWAYS OVERWRITTEN ON GENERATION.
--Audit Triggers For Version 0.0.0.0

--DROP ANY AUDIT TRIGGERS FOR [dbo].[Ancestor]
if exists(select * from sysobjects where name = '__TR_Ancestor__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Ancestor__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Ancestor__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Ancestor__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Ancestor__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Ancestor__DELETE]
GO

--CREATE TRIGGER INSERT FOR [dbo].[Ancestor]
CREATE TRIGGER [dbo].[__TR_Ancestor__INSERT]
ON [dbo].[Ancestor]
FOR INSERT AS
INSERT INTO [dbo].[__AUDIT__Ancestor] ([__action],[AncestorId],[Name],[ModifiedBy],[__insertdate])
SELECT 1, [AncestorId],[Name],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER UPDATE FOR [dbo].[Ancestor]
CREATE TRIGGER [dbo].[__TR_Ancestor__UPDATE]
ON [dbo].[Ancestor]
FOR UPDATE AS
INSERT INTO [dbo].[__AUDIT__Ancestor] ([__action],[AncestorId],[Name],[ModifiedBy],[__insertdate])
SELECT 2, [AncestorId],[Name],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER DELETE FOR [dbo].[Ancestor]
CREATE TRIGGER [dbo].[__TR_Ancestor__DELETE]
ON [dbo].[Ancestor]
FOR DELETE AS
INSERT INTO [dbo].[__AUDIT__Ancestor] ([__action],[AncestorId],[Name],[ModifiedBy],[__insertdate])
SELECT 3, [AncestorId],[Name],[ModifiedBy],getdate() FROM [deleted]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[Child]
if exists(select * from sysobjects where name = '__TR_Child__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Child__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Child__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Child__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Child__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Child__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[Descendant]
if exists(select * from sysobjects where name = '__TR_Descendant__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Descendant__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Descendant__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Descendant__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Descendant__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Descendant__DELETE]
GO

--CREATE TRIGGER INSERT FOR [dbo].[Descendant]
CREATE TRIGGER [dbo].[__TR_Descendant__INSERT]
ON [dbo].[Descendant]
FOR INSERT AS
INSERT INTO [dbo].[__AUDIT__Descendant] ([__action],[AncestorId],[FdecendantParentId],[LastName],[Price],[ModifiedBy],[__insertdate])
SELECT 1, [AncestorId],[FdecendantParentId],[LastName],[Price],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER UPDATE FOR [dbo].[Descendant]
CREATE TRIGGER [dbo].[__TR_Descendant__UPDATE]
ON [dbo].[Descendant]
FOR UPDATE AS
INSERT INTO [dbo].[__AUDIT__Descendant] ([__action],[AncestorId],[FdecendantParentId],[LastName],[Price],[ModifiedBy],[__insertdate])
SELECT 2, [AncestorId],[FdecendantParentId],[LastName],[Price],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER DELETE FOR [dbo].[Descendant]
CREATE TRIGGER [dbo].[__TR_Descendant__DELETE]
ON [dbo].[Descendant]
FOR DELETE AS
INSERT INTO [dbo].[__AUDIT__Descendant] ([__action],[AncestorId],[FdecendantParentId],[LastName],[Price],[ModifiedBy],[__insertdate])
SELECT 3, [AncestorId],[FdecendantParentId],[LastName],[Price],[ModifiedBy],getdate() FROM [deleted]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[DescendantParent]
if exists(select * from sysobjects where name = '__TR_DescendantParent__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DescendantParent__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_DescendantParent__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DescendantParent__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_DescendantParent__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DescendantParent__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[DoubleKeyIdentity]
if exists(select * from sysobjects where name = '__TR_DoubleKeyIdentity__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleKeyIdentity__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_DoubleKeyIdentity__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleKeyIdentity__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_DoubleKeyIdentity__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleKeyIdentity__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[DoubleLinkOneOneChild]
if exists(select * from sysobjects where name = '__TR_DoubleLinkOneOneChild__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleLinkOneOneChild__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_DoubleLinkOneOneChild__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleLinkOneOneChild__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_DoubleLinkOneOneChild__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleLinkOneOneChild__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[DoubleLinkOneOneParent]
if exists(select * from sysobjects where name = '__TR_DoubleLinkOneOneParent__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleLinkOneOneParent__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_DoubleLinkOneOneParent__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleLinkOneOneParent__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_DoubleLinkOneOneParent__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_DoubleLinkOneOneParent__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[GuidLinkChild]
if exists(select * from sysobjects where name = '__TR_GuidLinkChild__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_GuidLinkChild__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_GuidLinkChild__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_GuidLinkChild__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_GuidLinkChild__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_GuidLinkChild__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[GuidLinkParent]
if exists(select * from sysobjects where name = '__TR_GuidLinkParent__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_GuidLinkParent__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_GuidLinkParent__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_GuidLinkParent__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_GuidLinkParent__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_GuidLinkParent__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[Left]
if exists(select * from sysobjects where name = '__TR_Left__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Left__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Left__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Left__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Left__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Left__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[LeftRight]
if exists(select * from sysobjects where name = '__TR_LeftRight__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_LeftRight__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_LeftRight__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_LeftRight__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_LeftRight__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_LeftRight__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[ManyTypes]
if exists(select * from sysobjects where name = '__TR_ManyTypes__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_ManyTypes__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_ManyTypes__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_ManyTypes__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_ManyTypes__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_ManyTypes__DELETE]
GO

--CREATE TRIGGER INSERT FOR [dbo].[ManyTypes]
CREATE TRIGGER [dbo].[__TR_ManyTypes__INSERT]
ON [dbo].[ManyTypes]
FOR INSERT AS
INSERT INTO [dbo].[__AUDIT__ManyTypes] ([__action],[GuidId],[TestBigint],[TestBinary],[TestBit],[Testcalculated],[TestChar],[TestDate],[TestDatetime],[TestDatetime2],[TestDatetimeoffset],[TestDecimal],[TestFloat],[TestInt],[TestMoney],[TestNchar],[TestNvarchar],[TestReal],[TestSmalldatetime],[TestSmallint],[TestSmallmoney],[TestTime],[TestTinyint],[TestUniqueidentifier],[TestVarbinary],[TestVarchar],[TestXml],[Varcharmax],[ModifiedBy],[__insertdate])
SELECT 1, [GuidId],[TestBigint],[TestBinary],[TestBit],[Testcalculated],[TestChar],[TestDate],[TestDatetime],[TestDatetime2],[TestDatetimeoffset],[TestDecimal],[TestFloat],[TestInt],[TestMoney],[TestNchar],[TestNvarchar],[TestReal],[TestSmalldatetime],[TestSmallint],[TestSmallmoney],[TestTime],[TestTinyint],[TestUniqueidentifier],[TestVarbinary],[TestVarchar],[TestXml],[Varcharmax],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER UPDATE FOR [dbo].[ManyTypes]
CREATE TRIGGER [dbo].[__TR_ManyTypes__UPDATE]
ON [dbo].[ManyTypes]
FOR UPDATE AS
INSERT INTO [dbo].[__AUDIT__ManyTypes] ([__action],[GuidId],[TestBigint],[TestBinary],[TestBit],[Testcalculated],[TestChar],[TestDate],[TestDatetime],[TestDatetime2],[TestDatetimeoffset],[TestDecimal],[TestFloat],[TestInt],[TestMoney],[TestNchar],[TestNvarchar],[TestReal],[TestSmalldatetime],[TestSmallint],[TestSmallmoney],[TestTime],[TestTinyint],[TestUniqueidentifier],[TestVarbinary],[TestVarchar],[TestXml],[Varcharmax],[ModifiedBy],[__insertdate])
SELECT 2, [GuidId],[TestBigint],[TestBinary],[TestBit],[Testcalculated],[TestChar],[TestDate],[TestDatetime],[TestDatetime2],[TestDatetimeoffset],[TestDecimal],[TestFloat],[TestInt],[TestMoney],[TestNchar],[TestNvarchar],[TestReal],[TestSmalldatetime],[TestSmallint],[TestSmallmoney],[TestTime],[TestTinyint],[TestUniqueidentifier],[TestVarbinary],[TestVarchar],[TestXml],[Varcharmax],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER DELETE FOR [dbo].[ManyTypes]
CREATE TRIGGER [dbo].[__TR_ManyTypes__DELETE]
ON [dbo].[ManyTypes]
FOR DELETE AS
INSERT INTO [dbo].[__AUDIT__ManyTypes] ([__action],[GuidId],[TestBigint],[TestBinary],[TestBit],[Testcalculated],[TestChar],[TestDate],[TestDatetime],[TestDatetime2],[TestDatetimeoffset],[TestDecimal],[TestFloat],[TestInt],[TestMoney],[TestNchar],[TestNvarchar],[TestReal],[TestSmalldatetime],[TestSmallint],[TestSmallmoney],[TestTime],[TestTinyint],[TestUniqueidentifier],[TestVarbinary],[TestVarchar],[TestXml],[Varcharmax],[ModifiedBy],[__insertdate])
SELECT 3, [GuidId],[TestBigint],[TestBinary],[TestBit],[Testcalculated],[TestChar],[TestDate],[TestDatetime],[TestDatetime2],[TestDatetimeoffset],[TestDecimal],[TestFloat],[TestInt],[TestMoney],[TestNchar],[TestNvarchar],[TestReal],[TestSmalldatetime],[TestSmallint],[TestSmallmoney],[TestTime],[TestTinyint],[TestUniqueidentifier],[TestVarbinary],[TestVarchar],[TestXml],[Varcharmax],[ModifiedBy],getdate() FROM [deleted]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[OneToOneChild]
if exists(select * from sysobjects where name = '__TR_OneToOneChild__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_OneToOneChild__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_OneToOneChild__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_OneToOneChild__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_OneToOneChild__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_OneToOneChild__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[OneToOneParent]
if exists(select * from sysobjects where name = '__TR_OneToOneParent__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_OneToOneParent__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_OneToOneParent__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_OneToOneParent__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_OneToOneParent__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_OneToOneParent__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[Parent]
if exists(select * from sysobjects where name = '__TR_Parent__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Parent__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Parent__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Parent__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Parent__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Parent__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[ParentType]
if exists(select * from sysobjects where name = '__TR_ParentType__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_ParentType__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_ParentType__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_ParentType__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_ParentType__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_ParentType__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[Right]
if exists(select * from sysobjects where name = '__TR_Right__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Right__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Right__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Right__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Right__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Right__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[Simple]
if exists(select * from sysobjects where name = '__TR_Simple__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Simple__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Simple__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Simple__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Simple__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_Simple__DELETE]
GO

--CREATE TRIGGER INSERT FOR [dbo].[Simple]
CREATE TRIGGER [dbo].[__TR_Simple__INSERT]
ON [dbo].[Simple]
FOR INSERT AS
INSERT INTO [dbo].[__AUDIT__Simple] ([__action],[MyReadonly],[Name],[NewInt],[SimpleId],[ModifiedBy],[__insertdate])
SELECT 1, [MyReadonly],[Name],[NewInt],[SimpleId],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER UPDATE FOR [dbo].[Simple]
CREATE TRIGGER [dbo].[__TR_Simple__UPDATE]
ON [dbo].[Simple]
FOR UPDATE AS
INSERT INTO [dbo].[__AUDIT__Simple] ([__action],[MyReadonly],[Name],[NewInt],[SimpleId],[ModifiedBy],[__insertdate])
SELECT 2, [MyReadonly],[Name],[NewInt],[SimpleId],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER DELETE FOR [dbo].[Simple]
CREATE TRIGGER [dbo].[__TR_Simple__DELETE]
ON [dbo].[Simple]
FOR DELETE AS
INSERT INTO [dbo].[__AUDIT__Simple] ([__action],[MyReadonly],[Name],[NewInt],[SimpleId],[ModifiedBy],[__insertdate])
SELECT 3, [MyReadonly],[Name],[NewInt],[SimpleId],[ModifiedBy],getdate() FROM [deleted]
GO

--DROP ANY AUDIT TRIGGERS FOR [dbo].[TreeNode]
if exists(select * from sysobjects where name = '__TR_TreeNode__INSERT' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_TreeNode__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_TreeNode__UPDATE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_TreeNode__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_TreeNode__DELETE' AND xtype = 'TR')
DROP TRIGGER [dbo].[__TR_TreeNode__DELETE]
GO

--CREATE TRIGGER INSERT FOR [dbo].[TreeNode]
CREATE TRIGGER [dbo].[__TR_TreeNode__INSERT]
ON [dbo].[TreeNode]
FOR INSERT AS
INSERT INTO [dbo].[__AUDIT__TreeNode] ([__action],[FparentTreeNodeId],[Name],[TreeNodeId],[ModifiedBy],[__insertdate])
SELECT 1, [FparentTreeNodeId],[Name],[TreeNodeId],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER UPDATE FOR [dbo].[TreeNode]
CREATE TRIGGER [dbo].[__TR_TreeNode__UPDATE]
ON [dbo].[TreeNode]
FOR UPDATE AS
INSERT INTO [dbo].[__AUDIT__TreeNode] ([__action],[FparentTreeNodeId],[Name],[TreeNodeId],[ModifiedBy],[__insertdate])
SELECT 2, [FparentTreeNodeId],[Name],[TreeNodeId],[ModifiedBy],getdate() FROM [inserted]
GO

--CREATE TRIGGER DELETE FOR [dbo].[TreeNode]
CREATE TRIGGER [dbo].[__TR_TreeNode__DELETE]
ON [dbo].[TreeNode]
FOR DELETE AS
INSERT INTO [dbo].[__AUDIT__TreeNode] ([__action],[FparentTreeNodeId],[Name],[TreeNodeId],[ModifiedBy],[__insertdate])
SELECT 3, [FparentTreeNodeId],[Name],[TreeNodeId],[ModifiedBy],getdate() FROM [deleted]
GO

